"use strict";
cc._RF.push(module, 'd9184GUYMtLdJGee7dzk5A6', 'BottomUI');
// scripts/BottomUI.ts

Object.defineProperty(exports, "__esModule", { value: true });
var Model_1 = require("./Model");
var WxUtil_1 = require("./WxUtil");
var Core_1 = require("./Core");
var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
var BottomUI = /** @class */ (function (_super) {
    __extends(BottomUI, _super);
    function BottomUI() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.tipNode = null;
        _this.tipLabel = null;
        _this.clickShare = false;
        _this.clickShareTime = 0;
        return _this;
        // update (dt) {}
    }
    BottomUI.prototype.onLoad = function () {
        Core_1.default.dispatcher.add('wxVideoEvent', this.onVideoEvent, this);
    };
    BottomUI.prototype.start = function () {
        this.tipLabel.string = Model_1.default.game.tipCount + '';
        this.tipNode.active = Model_1.default.game.tipCount > 0;
        // WxUtil.onShow(this.onWXShow.bind(this))
    };
    BottomUI.prototype.onShareClick = function () {
        this.clickShare = true;
        this.clickShareTime = new Date().getTime();
        WxUtil_1.default.share();
    };
    BottomUI.prototype.onWXShow = function () {
        if (this.clickShare) {
            var now = new Date().getTime();
            if (now - this.clickShareTime >= 3000) //停留在微信界面3秒
             {
                Model_1.default.game.tipCount++;
                this.tipNode.active = Model_1.default.game.tipCount > 0;
                this.tipLabel.string = Model_1.default.game.tipCount + '';
            }
            this.clickShare = false;
        }
    };
    BottomUI.prototype.onReplayClick = function () {
        if (Model_1.default.game.selectedModel == 1)
            cc.director.loadScene('game');
        else if (Model_1.default.game.selectedModel == 2)
            cc.director.loadScene('gameDrop');
        else if (Model_1.default.game.selectedModel == 3)
            cc.director.loadScene('gameDrag');
        else if (Model_1.default.game.selectedModel == 4)
            cc.director.loadScene('gameDraw');
    };
    BottomUI.prototype.onTipClick = function () {
        if (Model_1.default.game.tipCount > 0) {
            Model_1.default.game.tipCount--;
            this.tipNode.active = Model_1.default.game.tipCount > 0;
            this.tipLabel.string = Model_1.default.game.tipCount + '';
            this.node.emit('showTip');
        }
        else {
            //WxUtil.showTip('暂无视频可用,分享好友也可以增加提示哦!')
            WxUtil_1.default.showVideo();
        }
    };
    BottomUI.prototype.onVideoEvent = function (v) {
        if (v == 1) {
            Model_1.default.game.tipCount++;
            this.tipNode.active = Model_1.default.game.tipCount > 0;
            this.tipLabel.string = Model_1.default.game.tipCount + '';
        }
    };
    BottomUI.prototype.onDestroy = function () {
        Core_1.default.dispatcher.remove('wxVideoEvent', this.onVideoEvent, this);
    };
    __decorate([
        property(cc.Node)
    ], BottomUI.prototype, "tipNode", void 0);
    __decorate([
        property(cc.Label)
    ], BottomUI.prototype, "tipLabel", void 0);
    BottomUI = __decorate([
        ccclass
    ], BottomUI);
    return BottomUI;
}(cc.Component));
exports.default = BottomUI;

cc._RF.pop();